// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;

public final class TilePropertyAliasMap {
    public static final TilePropertyAliasMap instance = new TilePropertyAliasMap();
    public final HashMap<String, Integer> PropertyToID = new HashMap();
    public final ArrayList<TilePropertyAliasMap.TileProperty> Properties = new ArrayList();

    public void Generate(HashMap<String, ArrayList<String>> propertyValueMap) {
        this.Properties.clear();
        this.PropertyToID.clear();

        for (Entry entry : propertyValueMap.entrySet()) {
            String string0 = (String)entry.getKey();
            ArrayList arrayList0 = (ArrayList)entry.getValue();
            this.PropertyToID.put(string0, this.Properties.size());
            TilePropertyAliasMap.TileProperty tileProperty = new TilePropertyAliasMap.TileProperty();
            this.Properties.add(tileProperty);
            tileProperty.propertyName = string0;
            tileProperty.possibleValues.addAll(arrayList0);
            ArrayList arrayList1 = tileProperty.possibleValues;

            for (int _int = 0; _int < arrayList1.size(); _int++) {
                String string1 = (String)arrayList1.get(_int);
                tileProperty.idMap.put(string1, _int);
            }
        }
    }

    public int getIDFromPropertyName(String name) {
        return !this.PropertyToID.containsKey(name) ? -1 : (Integer)this.PropertyToID.get(name);
    }

    public int getIDFromPropertyValue(int property, String value) {
        TilePropertyAliasMap.TileProperty tileProperty = (TilePropertyAliasMap.TileProperty)this.Properties.get(property);
        if (tileProperty.possibleValues.isEmpty()) {
            return 0;
        } else {
            return !tileProperty.idMap.containsKey(value) ? 0 : (Integer)tileProperty.idMap.get(value);
        }
    }

    public String getPropertyValueString(int property, int value) {
        TilePropertyAliasMap.TileProperty tileProperty = (TilePropertyAliasMap.TileProperty)this.Properties.get(property);
        return tileProperty.possibleValues.isEmpty() ? "" : (String)tileProperty.possibleValues.get(value);
    }

    public static final class TileProperty {
        public String propertyName;
        public final ArrayList<String> possibleValues = new ArrayList();
        public final HashMap<String, Integer> idMap = new HashMap();
    }
}
